<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 19-4-2
 * Time: 下午3:47
 */

namespace api\modules\nbrb\controllers;


use common\components\huaxiayinhang\Config;
use common\components\huaxiayinhang\Nbrb;
use common\components\tools\OpensslRSA;
use common\components\tools\Tools;
use wodrow\yii\rest\Controller;
use GuzzleHttp\Client;

class DefaultController extends Controller
{
    /**
     * 14.附件上传
     * @param string 人保订单号 $orderNumber
     * @param string $attachmentType 附件类型
     * @param string $file_url 附件地址
     * @param int $number 序号，同种类型附件有多份时需要，第一份不需要需要，第二份开始使用序号1,2,3
     * @return array
     * @throws
     */
    public function actionAttachmentUpload($orderNumber = '', $attachmentType, $file_url, $number = 0)
    {
        $nbrb = new Nbrb();
        $r = $nbrb->attachmentUpload($orderNumber, $attachmentType, $file_url, $number);
        return $r;
    }

    /**
     * 1.客户准入
     * @desc get/post详见https://www.showdoc.cc/nbrbhxyh?page_id=1530835857190977
     * @param string $json 示例:{"name":"张三","certType":"01","certNo":"110101199003076851","phone":"13735254152","maritalStatus":"01","idvalidStart":"2018-05-01","idvalidEnd":"2059-12-21","attachlist":["loanercardfront15542758970947307","loanerface15542766086828436","loaner3rdauth15542766149051246","loanercreditauth15542766208799430","loanercardback15542766341332235"],"bankCode":"HXBK","carUsage":"01","businessType":"BUS_001","carStruct":"CC_001","isDualSign":"N","hasMate":"N","mateInfo":{"name":"","certType":"","certNo":"","phone":"","attachlist":""},"hasGuar1":"N","guar1Info":{"name":"","certType":"","certNo":"","phone":"","relation":"","attachlist":""},"hasGuar2":"N","guar2Info":{"name":"","certType":"","certNo":"","phone":"","relation":"","attachlist":""}}
     * @param integer $force 强制重新请求
     * @throws
     */
    public function actionCustomAdmittance($json, $force = 0)
    {
        $json = json_encode(json_decode($json, true), JSON_UNESCAPED_UNICODE);
        $nbrb = new Nbrb();
        $r = $nbrb->customAdmittance($json, $force);
        return $r;
    }

    /**
     * 3.核保申请
     * @get/post
     * @param string $json
     * @param integer $force 强制重新请求
     * @throws
     */
    public function actionUnderwriteApply($json, $force = 0)
    {
        $json = json_encode(json_decode($json, true), JSON_UNESCAPED_UNICODE);
        $nbrb = new Nbrb();
        $r = $nbrb->underwriteApply($json, $force);
        return $r;
    }

    /**
     * 5.车辆信息补录
     * @get/post
     * @param string $json
     * @param integer $force 强制重新请求
     * @throws
     */
    public function actionAdditionalRecordApply($json, $force = 0)
    {
        $json = json_encode(json_decode($json, true), JSON_UNESCAPED_UNICODE);
        $nbrb = new Nbrb();
        $r = $nbrb->additionalRecordApply($json, $force);
        return $r;
    }

    /**
     * 7.终审请求
     * @get/post
     * @param string $json
     * @param integer $force 强制重新请求
     * @throws
     */
    public function actionFinalAduitApply($json, $force = 0)
    {
        $json = json_encode(json_decode($json, true), JSON_UNESCAPED_UNICODE);
        $nbrb = new Nbrb();
        $r = $nbrb->finalAduitApply($json, $force);
        return $r;
    }

    /**
     * 9.放款申请
     * @get/post
     * @param string $json
     * @param integer $force 强制重新请求
     * @throws
     */
    public function actionLoanApply($json, $force = 0)
    {
        $json = json_encode(json_decode($json, true), JSON_UNESCAPED_UNICODE);
        $nbrb = new Nbrb();
        $r = $nbrb->loanApply($json, $force);
        return $r;
    }

    /**
     * 11.保单信息获取
     * @get/post
     * @param string $json
     * @param integer $force 强制重新请求
     * @throws
     */
    public function actionGetPolicyDetail($json, $force = 0)
    {
        $json = json_encode(json_decode($json, true), JSON_UNESCAPED_UNICODE);
        $nbrb = new Nbrb();
        $r = $nbrb->getPolicyDetail($json, $force);
        return $r;
    }

    /**
     * 12.抵押信息推送
     * @get/post
     * @param string $json
     * @param integer $force 强制重新请求
     * @throws
     */
    public function actionPledgeInfoNotice($json, $force = 0)
    {
        $json = json_encode(json_decode($json, true), JSON_UNESCAPED_UNICODE);
        $nbrb = new Nbrb();
        $r = $nbrb->pledgeInfoNotice($json, $force);
        return $r;
    }

    /**
     * 15.贷后阶段-还款计划信息获取
     * @get/post
     * @param string $json
     * @param integer $force 强制重新请求
     * @throws
     */
    public function actionGetRepayPlanDetail($json, $force = 0)
    {
        $json = json_encode(json_decode($json, true), JSON_UNESCAPED_UNICODE);
        $nbrb = new Nbrb();
        $r = $nbrb->getRepayPlanDetail($json, $force);
        return $r;
    }

    /**
     * 19.获取附件
     * @get/post
     * @param string $json
     * @param integer $force 强制重新请求
     * @throws
     */
    public function actionGetFile($json, $force = 0)
    {
        $json = json_encode(json_decode($json, true), JSON_UNESCAPED_UNICODE);
        $nbrb = new Nbrb();
        $r = $nbrb->getFile($json, $force);
        return $r;
    }
}